package com.ruoyi.web.service.impl;

import java.util.List;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.mapper.DrugEnterpriseMapper;
import com.ruoyi.web.domain.DrugEnterprise;
import com.ruoyi.web.service.IDrugEnterpriseService;
import com.ruoyi.common.core.text.Convert;

/**
 * 药品药企Service业务层处理
 * 
 * @author drx
 * @date 2025-05-13
 */
@Service
public class DrugEnterpriseServiceImpl implements IDrugEnterpriseService 
{
    @Autowired
    private DrugEnterpriseMapper drugEnterpriseMapper;

    /**
     * 查询药品药企
     * 
     * @param id 药品药企主键
     * @return 药品药企
     */
    @Override
    public DrugEnterprise selectDrugEnterpriseById(Long id)
    {
        return drugEnterpriseMapper.selectDrugEnterpriseById(id);
    }

    /**
     * 查询药品药企列表
     * 
     * @param drugEnterprise 药品药企
     * @return 药品药企
     */
    @Override
    public List<DrugEnterprise> selectDrugEnterpriseList(DrugEnterprise drugEnterprise)
    {
        return drugEnterpriseMapper.selectDrugEnterpriseList(drugEnterprise);
    }

    /**
     * 新增药品药企
     * 
     * @param drugEnterprise 药品药企
     * @return 结果
     */
    @Override
    public int insertDrugEnterprise(DrugEnterprise drugEnterprise)
    {
        drugEnterprise.setCreateTime(DateUtils.getNowDate());
        drugEnterprise.setCreateBy(ShiroUtils.getSysUser().getLoginName());
        drugEnterprise.setCreateName(ShiroUtils.getSysUser().getUserName());
        drugEnterprise.setUpdateTime(DateUtils.getNowDate());
        drugEnterprise.setUpdateBy(ShiroUtils.getSysUser().getLoginName());
        drugEnterprise.setUpdateName(ShiroUtils.getSysUser().getUserName());
        return drugEnterpriseMapper.insertDrugEnterprise(drugEnterprise);
    }

    /**
     * 修改药品药企
     * 
     * @param drugEnterprise 药品药企
     * @return 结果
     */
    @Override
    public int updateDrugEnterprise(DrugEnterprise drugEnterprise)
    {
        drugEnterprise.setUpdateTime(DateUtils.getNowDate());
        drugEnterprise.setUpdateBy(ShiroUtils.getSysUser().getLoginName());
        drugEnterprise.setUpdateName(ShiroUtils.getSysUser().getUserName());
        return drugEnterpriseMapper.updateDrugEnterprise(drugEnterprise);
    }

    /**
     * 批量删除药品药企
     * 
     * @param ids 需要删除的药品药企主键
     * @return 结果
     */
    @Override
    public int deleteDrugEnterpriseByIds(String ids)
    {
        return drugEnterpriseMapper.deleteDrugEnterpriseByIds(Convert.toStrArray(ids),ShiroUtils.getSysUser().getLoginName());
    }

    /**
     * 删除药品药企信息
     * 
     * @param id 药品药企主键
     * @return 结果
     */
    @Override
    public int deleteDrugEnterpriseById(Long id)
    {
        return drugEnterpriseMapper.deleteDrugEnterpriseById(id,ShiroUtils.getSysUser().getLoginName());
    }
}
